new Vue({
    el: '#app',
    data() {
        return {
            IO_form: {
                Data: 'employee',//状态
                page: 1,			//页数
                limit: 10,			//每页数据条数
                Enterprise_Info_SerialNumber: $.cookie('enterprise'),
            },
            Employees: [
                {
                    text: '组织1',
                    value: "1",
                    children: [{
                        text: '部门1',
                        value: '1-1'
                    }]
                },
                {
                    text: '组织2',
                    value: "2",
                    children: [{
                        text: '部门1',
                        value: '2-1'
                    }]
                },
                {
                    text: '组织3',
                    value: "3",
                    children: [{
                        text: '部门1',
                        value: '3-1'
                    }]
                },
            ],
            formData: {},
            IA_tableData: [{
                Organization_Name:"",
                Department_Name:"",
                Employee_Phone:"",
            }],		//表格数据
            II_total: 1,
            dialogForm: false,
            title: '',
            multipleSelection: [],
            data: [{
                label: '一级 1',
                children: [{
                    label: '二级 1-1',
                    children: [{
                        label: '三级 1-1-1'
                    }]
                }]
            }, {
                label: '一级 2',
                children: [{
                    label: '二级 2-1',
                    children: [{
                        label: '三级 2-1-1'
                    }]
                }, {
                    label: '二级 2-2',
                    children: [{
                        label: '三级 2-2-1'
                    }]
                }]
            }, {
                label: '一级 3',
                children: [{
                    label: '二级 3-1',
                    children: [{
                        label: '三级 3-1-1'
                    }]
                }, {
                    label: '二级 3-2',
                    children: [{
                        label: '三级 3-2-1'
                    }]
                }]
            }],
            defaultProps: {
                children: 'children',
                label: 'label'
            },
            IB_disabled: true
        }
    },
    mounted() {
        this.getList(this.IO_form)
        this.getEmployees()
    },
    methods: {
        handleNodeClick(data) {
            console.log(data);
        },
        handleSizeChange(val) {
            this.IO_form.page = 1;
            this.IO_form.limit = val;
            this.getList(this.IO_form)
        },
        //号码按键查询
        handleCurrentChange(val) {
            this.IO_form.page = val;
            this.getList(this.IO_form)
        },
        Addemployee() {
            window.location.href = './Add.html'
        },
        getEmployees() {
            const this_ = this
            $.ajax({
                url: DomainName + '/getOrganizationAction?token=' + $.cookie('token'),
                type: 'POST',
                data: {
                    Enterprise_Info_SerialNumber: $.cookie("enterprise"),
                },
                success: function (res) {
                    console.log(res)
                    this_.Employees = res.Data
                }
            })
        },
        getList(Arg) {     //换页方法
            let LF_this = this
            $.ajax({
                type: 'POST',
                url: DomainName + "/getEmployeeAllAction?token=" + $.cookie('token'),
                data: Arg,
                complete: function (XMLHttpRequest) {
                    if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                        window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                    }
                },
                success: function (Result) {
                    console.log(Result);
                    Result.tableData.forEach(item=>{
                        item.Employee_Phone = item.Employee_Phone.slice(0,3)+'****'+item.Employee_Phone.slice(7,11)
                    })
                    LF_this.IA_tableData = Result.tableData      //将获取的数据存到表格数据中
                    LF_this.II_total = Number(Result.limit)
                },
                dataType: "json"
            });
        },
        handleCheckChange(e){
            console.log(e)
        }
    },
})